import { ref } from 'vue';
import { GameKernel, EVENTS } from '../game';

const kernel = GameKernel.inst;

const state = ref(kernel.equipmentPanelSystem.getUISnapshot());

kernel.bus.on(EVENTS.EQUIPMENT_PANEL_STATE_UPDATE, () => {
  state.value = kernel.equipmentPanelSystem.getUISnapshot();
});
kernel.bus.on(EVENTS.GAME_LOADED, () => {
  state.value = kernel.equipmentPanelSystem.getUISnapshot();
});

export function useEquipmentPanel() {
  state.value = kernel.equipmentPanelSystem.getUISnapshot();
  return { state };
}
